﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ECC_EXT_Entity;
namespace ECCSystem
{
    public partial class frm_Ext_OFFCategoryItems : Form
    {
        private IList<OFFCategoryItemsEntity> _listInput;

        public frm_Ext_OFFCategoryItems(IList<OFFCategoryItemsEntity> _list)
        {
            InitializeComponent();
            this._listInput = _list;
        }

        private void frm_Ext_OFFCategoryItems_Load(object sender, EventArgs e)
        {
            this.LoadDataGrid();
        }

        private void LoadDataGrid()
        {
            IList<DataGridDto> _list = new List<DataGridDto>();
            foreach (var item in _listInput)
            {
                _list.Add(new DataGridDto(item.DICCategory));
            }

            this.dataGridView1.DataSource = _list;
        }

        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 1 && e.RowIndex != -1)
            {
                String str =
                    this.dataGridView1[e.ColumnIndex, e.RowIndex].Value.ToString();
                Clipboard.SetText(str);
                this.dataGridView1[0, e.RowIndex].Style.BackColor = Color.CornflowerBlue;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }

    internal class DataGridDto
    {
        public DataGridDto(DICOFFCategoryEntity _entity)
        {
            this.Name =
                _entity.Name;

            this.Code =
                _entity.Code;
        }

        public string Name { get; set; }
        public string Code { get; set; }
    }
}
